import numpy as np
a=np.array([1,2,1,3,4,5])
# 一维数组的多元素获取
print(a[[0,2]])


# 1. 算术运算
n1 = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
n2 = np.array([1, 2, 3])

add_result = np.add(n1, n2)
sub_result = np.subtract(n1, n2)
mul_result = np.multiply(n1, n2)
div_result = np.divide(n1, n2)

# 2. 排序
kpi_data = np.array([('Mary', 22, 95.5), ('LiLi', 23, 56), ('Cendy', 22, 90)], 
                    dtype=[('name', 'U10'), ('age', 'i4'), ('kpi', 'f4')])
sorted_by_kpi = np.sort(kpi_data, order='kpi')

# 3. 去重
arr = np.array([4, 7, 1, 6, 1, 8, 4, 9, 1, 6])
unique_arr = np.unique(arr)
print(f"kpi_data: {kpi_data}")
print(f"sorted_by_kpi: {sorted_by_kpi}")

